﻿<%@ WebHandler Language="C#" Class="station" %>

using System;
using System.Collections.Generic;
using System.Web;


/// <summary>
/// station 的摘要说明
/// </summary>
public class station : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "application/json";

        /*
        var js = HttpHelper.Get("https://kyfw.12306.cn/otn/resources/js/framework/station_name.js?station_version=1.8994");

        var strs = js.Replace("var station_names ='", "").Replace("';", "");
        var list = new List<StationItem>();
        foreach (var str in strs.Split(new string[] { "@" }, StringSplitOptions.RemoveEmptyEntries))
        {
            var arry = str.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);

            list.Add(new StationItem
            {
                NameE = arry[0],
                NameCN = arry[1],
                Code = arry[2],
                LongNameE = arry[3],
                NameE2 = arry[4],
                Id = arry[5],
            });
        }
        context.Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(list));
         */
        context.Response.Write(GetStation(context));
         
    }

    public string GetStation(HttpContext context)
    {
        var str = FileHelper.ReadFile(context.Server.MapPath("station.json"));
        return str;
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
}
public struct StationItem
{
    public string NameE { get; set; }
    public string NameCN { get; set; }

    public string Code { get; set; }
    public string LongNameE { get; set; }
    public string Id { get; set; }
    public string NameE2 { get; set; }
}